package me.huangxiang.design_pattern.template;

public abstract class CaffeineBeverage {
    final void prepareRecipe(){
        // 在抽象类中固定算法的流程
        boilWater();
        brew();
        pourInCup();

        if (customerWantsCondiments()){
            addCondiments();
        }
    }

    abstract void brew();

    abstract void addCondiments();

    void boilWater(){
        System.out.println("Boiling water.");
    }

    void pourInCup(){
        System.out.println("Pouring into cup.");
    }

    boolean customerWantsCondiments(){
        return true;
    }
}
